package com.soft.product;


import com.soft.dao.TProductDao;
import com.soft.entity.TProduct;
import org.junit.jupiter.api.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import java.util.Date;
import java.util.List;

@SpringBootTest
@RunWith(SpringRunner.class)
public class testTProduct {
    @Autowired
    TProductDao tProductDao;


    @Test
    void testQueryById(){
        int id = 1;
        System.out.println(tProductDao.queryById(1));
    }
    @Test
    void testInsert(){
        Date date = new Date(System.currentTimeMillis());
        TProduct tProduct = new TProduct(null, date, date, "312A4", "12", "无", 32F, 20, "插电板", null , null, null, 0, 10);
        tProductDao.insert(tProduct);
        System.out.println(tProductDao.queryById(2));
    }
    @Test
    void testOffset(){
        List<TProduct> list = tProductDao.queryAllByLimit(0,6);
        for(TProduct tProduct: list){
            System.out.println(tProduct.toString());
        }
    }
    @Test
    void testFindAll(){
        List<TProduct> list = tProductDao.findAllProdects();
        for (TProduct tProduct: list){
            System.out.println(tProduct.toString());
        }
    }
    @Test
    void testUpdata(){
//        Date date = new Date(System.currentTimeMillis());
//        TProduct tProduct = new TProduct(3, date, date, "312A4", "12", "无", 32F, 20, "插电板", null , null, null, 0, 10, 1);
//        tProductDao.update();
    }

    @Test
    public void testVagueFindAllProducts(){
        System.out.println(tProductDao.vagueFindAllProducts("ds"));
        System.out.println(tProductDao.vagueFindAllProducts(null));
    }
}
